package com.lemon.smartsafety.ui.adapter.common;

import android.view.View;

import com.lemon.smartsafety.R;
import com.lemon.smartsafety.entity.common.PanelRcvBaseDataI;
import com.lemon.smartsafety.listener.RecyclerTClickListener;
import com.lemon.smartsafety.utils.common.LoggerHelper;
import com.lemon.smartsafety.view.item.PanelIconItemView;

import kale.adapter.item.AdapterItem;

/**
 * Created by Cooliean on 16/3/24.
 */
public class PanelRcvBaseAdapterItem implements AdapterItem<PanelRcvBaseDataI> {
    private LoggerHelper loggerHelper = new LoggerHelper(PanelRcvBaseAdapterItem.class);
    private RecyclerTClickListener<PanelRcvBaseDataI> mClickListener;
    private PanelIconItemView                         mPanelIconItemView;


    private PanelRcvBaseDataI mData;
    private int               mPosition;

    public PanelRcvBaseAdapterItem(RecyclerTClickListener<PanelRcvBaseDataI> clickListener) {
        this.mClickListener = clickListener;
    }

    @Override
    public int getLayoutResId() {
        return R.layout.item_panel_item_view;
    }

    @Override
    public void bindViews(View root) {
        mPanelIconItemView = (PanelIconItemView) root.findViewById(R.id.pv_item_view);
    }

    @Override
    public void setViews() {
        mPanelIconItemView.getRippleView().setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mClickListener.onItemClick(mData, mPosition);
            }
        });
  /*      mPanelIconItemView.getRippleView().setOnRippleCompleteListener(new RippleView.OnRippleCompleteListener() {
            @Override
            public void onComplete(RippleView rippleView) {
                mClickListener.onItemClick(mData, mPosition);
            }
        });*/
    }

    @Override
    public void handleData(PanelRcvBaseDataI data, int position) {
        mData = data;
        mPosition = position;
        if (mPanelIconItemView != null) {
            mPanelIconItemView.setData(data, position);
        }
    }
}
